import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:json_annotation/json_annotation.dart';
part 'geojson.g.dart';

@JsonSerializable(explicitToJson: true)
class Geojson {
  GeojsonData? data;
  int? code;
  int? message;
  Geojson({this.data, this.code, this.message});

  factory Geojson.fromJson(Map<String, dynamic> json) =>
      _$GeojsonFromJson(json);
  Map<String, dynamic> toJson() => _$GeojsonToJson(this);
}

@JsonSerializable(explicitToJson: true)
class GeojsonData {
  String? displayFieldName;
  FieldaliasesData? fieldAliases;
  String? geometryType;
  SpatialreferenceData? spatialReference;
  List<FieldsData>? fields;
  List<FeaturesData>? features;

  GeojsonData({
    this.displayFieldName,
    this.fieldAliases,
    this.geometryType,
    this.spatialReference,
    this.fields,
    this.features,
  });

  factory GeojsonData.fromJson(Map<String, dynamic> json) =>
      _$GeojsonDataFromJson(json);
  Map<String, dynamic> toJson() => _$GeojsonDataToJson(this);
}

@JsonSerializable(explicitToJson: true)
class FeaturesData {
  AttributesData? attributes;
  GeometryData? geometry;

  FeaturesData({
    this.attributes,
    this.geometry,
  });

  factory FeaturesData.fromJson(Map<String, dynamic> json) =>
      _$FeaturesDataFromJson(json);
  Map<String, dynamic> toJson() => _$FeaturesDataToJson(this);
}

@JsonSerializable(explicitToJson: true)
class GeometryData {
  List<dynamic>? rings;

  GeometryData({
    this.rings,
  });

  factory GeometryData.fromJson(Map<String, dynamic> json) =>
      _$GeometryDataFromJson(json);
  Map<String, dynamic> toJson() => _$GeometryDataToJson(this);
}

// @JsonSerializable(explicitToJson: true)
// class RingsData {
//   List<double>? one;
//   List<double>? two;
//   List<double>? three;
//   List<double>? four;
//   List<double>? five;

//   RingsData({
//     this.one,
//     this.two,
//     this.three,
//     this.four,
//     this.five,
//   });

//   factory RingsData.fromJson(List<dynamic> json) =>
//       _$RingsDataFromJson(json);
//   Map<String, dynamic> toJson() => _$RingsDataToJson(this);
// }

@JsonSerializable(explicitToJson: true)
class AttributesData {
  int? FID;
  int? OID_;
  double? Shape_Leng;
  double? Shape_Area;

  AttributesData({
    this.FID,
    this.OID_,
    this.Shape_Leng,
    this.Shape_Area,
  });

  factory AttributesData.fromJson(Map<String, dynamic> json) =>
      _$AttributesDataFromJson(json);
  Map<String, dynamic> toJson() => _$AttributesDataToJson(this);
}

@JsonSerializable(explicitToJson: true)
class FieldsData {
  String? name;
  String? type;
  String? alias;

  FieldsData({
    this.name,
    this.type,
    this.alias,
  });

  factory FieldsData.fromJson(Map<String, dynamic> json) =>
      _$FieldsDataFromJson(json);
  Map<String, dynamic> toJson() => _$FieldsDataToJson(this);
}

@JsonSerializable(explicitToJson: true)
class SpatialreferenceData {
  int? wkid;
  int? latestWkid;

  SpatialreferenceData({
    this.wkid,
    this.latestWkid,
  });

  factory SpatialreferenceData.fromJson(Map<String, dynamic> json) =>
      _$SpatialreferenceDataFromJson(json);
  Map<String, dynamic> toJson() => _$SpatialreferenceDataToJson(this);
}

@JsonSerializable(explicitToJson: true)
class FieldaliasesData {
  String? FID;
  String? OID_;
  String? Shape_Leng;
  String? Shape_Area;

  FieldaliasesData({
    this.FID,
    this.OID_,
    this.Shape_Leng,
    this.Shape_Area,
  });

  factory FieldaliasesData.fromJson(Map<String, dynamic> json) =>
      _$FieldaliasesDataFromJson(json);
  Map<String, dynamic> toJson() => _$FieldaliasesDataToJson(this);
}
